package com.greensecurity.sim.repository;

import com.greensecurity.sim.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;


@Repository
public interface UserRepository extends JpaRepository<User, Long> {
    User findByUserName(String username);

    User findByPhone(String phone);

    @Query(value = "SELECT COUNT(*) FROM user_role WHERE role_id = ?1",nativeQuery = true)
    String selectAdminOrWaringOrInsectUserNum(String roleId);

    @Query(value = "SELECT COUNT(*) FROM `user`",nativeQuery = true)
    Integer selectAllUserNum();
}